<template>
	<view class="wui-cell" hover-class="wui-cell-hover" :class="[{ 'wui-cell-border-bottom': borderBottom }]" @click="e => $emit('click', e)">
		<view class="wui-cell-left">
			<view class="cell-title">
				<text class="iconfont"  v-if="icon" :style="[iconColorComputed]" :class="[icon]"></text>
				<text class="title-text">{{ title }}</text>
			</view>
			<view class="cell-label" v-if="label">{{ label }}</view>
		</view>
		<view class="wui-cell-right">
			<text class="right-text" v-if="value">{{ value }}</text>
			<slot v-else name="value"></slot>
			<text v-if="arrow" class="iconfont icon-wui-right"></text>
		</view>
	</view>
</template>

<script>
export default {
	name: 'w-cell',
	props: {
		title: {
			type: String,
			default: '标题'
		},
		arrow: {
			type: Boolean,
			default: true
		},
		label: {
			type: String,
		},
		value: {
			type: String,
		},
		icon: {
			type: String,
		},
		iconColor: {
			type: String,
			default: '#333'
		},
		borderBottom: {
			type: Boolean,
			default: true
		}
	},
	computed:{
		iconColorComputed(){
			return {
				'--icon-color':this.iconColor
			}
		}
	}
};
</script>

<style lang="scss" scoped>
.wui-cell {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 30rpx;
	background-color: #fff;
	.wui-cell-left {
		display: flex;
		flex-direction: column;
		justify-content: center;
		flex: 3;
		.cell-title {
			display: flex;
			align-items: center;
			.iconfont {
				margin-right: 10rpx;
				font-size: 40rpx;
				color: var(--icon-color);
			}
		}
		.cell-label {
			margin-top: 10rpx;
			color: #909399;
			font-size: 22rpx;
		}
	}
	.wui-cell-right {
		display: flex;
		align-items: center;
		.iconfont {
			margin-left: 10rpx;
			color: #909399;
		}
	}
}
.wui-cell-hover {
	background-color: #F7F8F9;
}
.wui-cell-border-bottom {
	position: relative;
	// border-bottom: 2rpx solid #e4e7ed;
}
.wui-cell-border-bottom:after{
	content: '';
	position: absolute;
	left: 0;
	bottom: 0;
	width: 100%;
	border-bottom: 1px solid #e4e7ed;
	transform-origin: left  bottom;
	transform: scale( 0  0.5);
}
</style>
